<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    function fn(data){
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          console.log(data);
          resolve()
        }, 1000)
      })
    }

    // 解决异步回调的问题
    let p = fn(1);
    p.then(res => {
      return fn(2);
    }).then(res => {
      return fn(3);
    })
  </script>
</body>
</html>